package javase.ch02.homeWork.Test1;

/**
 * 创建对象的方式有哪些？总结并写代码
 * 1.直接通过new关键字创建
 *      调用类的构造方法初始化对象
 */
public class NewGirlfriend {
    private String name;
    private int age;
    private double height;

    public NewGirlfriend() {}

    public NewGirlfriend(String name, int age, double height) {
        this.name = name;
        this.age = age;
        this.height = height;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public double getHeight() {
        return height;
    }

    public void setHeight(double height) {
        this.height = height;
    }

    @Override
    public String toString() {
        return "Girlfriend{" +
                "姓名='" + name + '\'' +
                ", 年龄=" + age +
                ", 身高=" + height +
                '}';
    }
}

class Test {
    public static void main(String[] args) {
        NewGirlfriend s1 = new NewGirlfriend("小美",20,1.71);
        System.out.println(s1);

    }
}
